package com.muyi.mapper;

import com.muyi.pojo.entity.Category;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
* @author VRMMO
* @description 针对表【category】的数据库操作Mapper
* @createDate 2025-06-11 15:04:41
* @Entity com.muyi.pojo.entity.Category
*/
@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    /**
     * 查询全部分类
     * @return
     */
    @Select("select * from category")
    List<Category> list();

    /**
     * 根据ID删除分类
     * @param category_id
     */
    @Delete("delete from category where category_id = #{category_id}")
    void deleteById(Integer category_id);

    /**
     * 新增分类
     *
     * @param category
     * @return
     */
    @Insert("insert into category(category_name) values(#{category_name})")
    int insert(Category category);


    /**
     * 更新分类
     * @param category
     */
    @Update("update category set category_name=#{category_name} where category_id=#{category_id}")
    void update(Category category);

    @Select("select * from category where category_id = #{category_id}")
    Category getByCategoryId(Integer category_id);
}




